package com.gopay.scheduler.job.vo;

import java.io.Serializable;
import java.lang.reflect.Field;

import org.apache.log4j.Logger;

import oracle.net.aso.d;
/**
 * 实名认证接口 请求参数封装
 * @CertificationReqParamVo.java
 * @author zhaojunting
 * @2016年5月19日 下午2:55:28  www.gopay.com.cn Inc.All rights reserved.
 */
public class CertificationReqParamVo implements Serializable{

    private static final long serialVersionUID = -1772734066131157158L;

    private Logger log = Logger.getLogger(this.getClass());
    
    /*  相关参数查看开放数据平台    */
    
    /*系统参数*/
    
    /* API服务接口请求调用地址 :URL */
    private String URL ;
    
    /* API接口名称:  Method   */
    private String method ;
    
    /* app密钥:   Appsecret*/
    private String appSecret;
    
    /* 应用票据 :  AccessToken*/
    private String accessToken;
    
    /*应用参数*/
    
    /*系统代码:SYS_NO*/
    private String sysNo;
    
    /*证件类型 :CERT_TYP_CD*/
    private String certTypCd;

    public String getURL() {
        return URL;
    }

    public void setURL(String uRL) {
        URL = uRL;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getAppSecret() {
        return appSecret;
    }

    public void setAppSecret(String appSecret) {
        this.appSecret = appSecret;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getSysNo() {
        return sysNo;
    }

    public void setSysNo(String sysNo) {
        this.sysNo = sysNo;
    }

    public String getCertTypCd() {
        return certTypCd;
    }

    public void setCertTypCd(String certTypCd) {
        this.certTypCd = certTypCd;
    }
    
    public boolean validate(){
        boolean isOk = true;
        Field[] fields = getClass().getDeclaredFields();
        for(Field f : fields){
            if("serialVersionUID".equals(f.getName()) || "log".equals(f.getName())){
                continue;
            }
            f.setAccessible(true);
            Object value = null;
            try {
                value = f.get(this);
            } catch (IllegalArgumentException e) {
                log.warn(getClass().getName() + "--->" + e.getMessage());
                isOk = false;
            } catch (IllegalAccessException e) {
                log.warn(getClass().getName() + "--->" + e.getMessage());
                isOk = false;
            }
            if(value == null){
                isOk = false;
//                log.warn(getClass().getSimpleName() + "中" + f.getName() + "参数未初始化！");
            }
            
        }
//        log.info("实名认证参数验证 ：  " + toString());
        if(!isOk){
            throw new RuntimeException("CertificationReqParamVo未完成初始化！ " + toString());
        }
        return isOk;
    }

    @Override
    public String toString() {
        return "CertificationReqParamVo [URL=" + URL + ", method=" + method + ", appSecret=" + appSecret
                + ", accessToken=" + accessToken + ", sysNo=" + sysNo + ", certTypCd=" + certTypCd + "]";
    }
    
    
}
